home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / Oberon / source / amiga / RVI.mod < prev    next >
Text File  |  1995-06-29  |  4KB  |  104 lines

  1. (*(***********************************************************************
  2.  
  3. :Program.    RVI.mod
  4. :Contents.   Oberon Interface for the REXX Variables Interface
  5. :Support.    RVI (rexxvars.o) (C) by William S. Hawes
  6. :Author.     Martin Horneffer
  7. :Copyright.  Freely Distributable
  8. :Language.   Oberon
  9. :Translator. Oberon-A Release 1.5, OC V5.16
  10. :History.     1.0  10 Feb 1992, Martin Horneffer
  11. :History.     1.1  01 Oct 1992, hartmut Goebel: use $JOIN
  12. :History.    40.15 28 Dec 1993, hartmut Goebel: adapted to Interfaces 40.15
  13. :History.     3.1  29 Dec 1994, Frank Copeland: adapted to Oberon-A Interfaces
  14. :Address.    Warmweiherstraße 18, W-5100 Aachen
  15. :Phone.      0(049)241-535233
  16. :Remark.     names of ARexx variable MUST be uppercase!
  17. :Remark.     STEMs are nothing but variables with names that
  18. :Remark.     contain a dot (".").
  19.  
  20. ***********************************************************************)*)
  21.  
  22. <* STANDARD- *> <*$ StackChk- *>
  23.  
  24. MODULE RVI ["rexxvars.o"];
  25.  
  26. (* REXX Variables Interface *)
  27.  
  28. IMPORT
  29.   e := Exec,
  30.   rx := Rexx,
  31.   SYSTEM;
  32.  
  33. (*
  34.  * CheckRexxMsg()
  35.  * Usage: boolean = CheckRexxMsg(message);
  36.  *
  37.  * This function verifies that the message pointer is a valid RexxMsg and
  38.  * that it came from an ARexx macro program.  The validation test is more
  39.  * stringent  than that performed by the ARexx library function IsRexx().
  40.  * The latter verifies that the message is tagged as a RexxMsg structure,
  41.  * but  not  that  it necessarily came from an ARexx macro program.  Each
  42.  * macro  program  installs a pointer to its global data structure in the
  43.  * command  message,  and this pointer is necessary to gain access to the
  44.  * symbol table.
  45.  *
  46.  * The return from the function will be non-zero (TRUE) if the message is
  47.  * valid, and 0 (FALSE) otherwise.
  48.  *)
  49. PROCEDURE CheckRexxMsg * ["CheckRexxMsg"](message[8]: rx.RexxMsgPtr): BOOLEAN;
  50.  
  51. (*
  52.  * GetRexxVar()
  53.  * Usage: error = GetRexxVar(message,variable,&value);
  54.  *
  55.  * This function retrieves the current value for the specified variable name.
  56.  * It first validates the message using CheckRexxMsg() and then, if the
  57.  * message pointer is valid, retrieves the value string and passes it in the
  58.  * supplied return pointer.  The return pointer is actually an argstring (an
  59.  * offset pointer to a RexxArg structure), but can be treated as a pointer
  60.  * to a null-terminated string.  The value must not be disturbed by the host.
  61.  *
  62.  * The function return will be zero if the value was successfully retrieved
  63.  * and non-zero otherwise.  An error code of 10 indicates an invalid message.
  64.  *)
  65. PROCEDURE GetRexxVarA1 * ["GetRexxVar"](message[8] : rx.RexxMsgPtr;
  66.                                         variable[9]: ARRAY OF CHAR): LONGINT;
  67. (* value returned in A1 *)
  68.  
  69. PROCEDURE GetRexxVar * (message  : rx.RexxMsgPtr;
  70.                         variable : ARRAY OF CHAR;
  71.                         VAR value: e.LSTRPTR): LONGINT;
  72.   <*$CopyArrays-*>
  73.   VAR error: LONGINT;
  74.   BEGIN
  75.     error := GetRexxVarA1(message,variable);
  76.     value := SYSTEM.VAL (e.LSTRPTR, SYSTEM.REG(9));
  77.     RETURN error;
  78.   END GetRexxVar;
  79.  
  80. (*
  81.  * SetRexxVar()
  82.  * Usage: error = SetRexxVar(message,variable,value,length);
  83.  *
  84.  * This  function  installs  a  value  in  the  specified  variable.   It
  85.  * validates  the  message pointer using CheckRexxMsg() and then installs
  86.  * the  value,  creating  a symbol table entry if required.  The value is
  87.  * supplied  as a pointer to a data area along with the total length; the
  88.  * data may contain arbitrary values and need not be null-terminated.
  89.  *
  90.  * The  function  return  will  be  zero  if  the call was successful and
  91.  * non-zero  otherwise.   The possible error codes are given in the table
  92.  * below.
  93.  *
  94.  *    Error Code  Reason for Failure
  95.  *        3       Insufficient storage
  96.  *        9       String too long
  97.  *       10       Invalid message
  98.  *)
  99. PROCEDURE SetRexxVar * ["SetRexxVar"](message[8] : rx.RexxMsgPtr;
  100.                                       variable[9]: ARRAY OF CHAR;
  101.                                       value[0]   : ARRAY OF CHAR;
  102.                                       length[1]  : LONGINT): LONGINT;
  103. END RVI.
  104.